package com.qf.controller;

import com.qf.component.Admin;
import com.qf.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @Author Ayases
 * @Date 2025/4/2 19:15
 * @Desc
 */
@Controller
public class AdminController {
    // 在控制层中需要使用业务层对象
    // 不再主动new对象,而是从容器中拿
    // @Autowired注解就会从容器中找到该类型的对象赋值给该变量
    // 即这就是属性赋值,也就是依赖注入,即DI
    @Autowired
    private AdminService adminService;
    @Autowired
    private Admin admin;

    static int count = 0;

    @RequestMapping("/login")
    public String login() {
        adminService.login();
        System.out.println(admin.toString()+" login :"+ ++count + " times");

        return "ok.html";
    }

}
